package net.trackhack.powerboard.client;

import java.io.Serializable;

import java.util.Date;


import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;


/* Relationships:
 *   PowerBoard entry is a lapTime recorded on a given 'Track'
 *   by a specific: 'Driver', using their 'Vehicle' & 'VehicleConfig' 
 *   at a certain time/date (or event)
 *      
 */

@PersistenceCapable(identityType= IdentityType.APPLICATION)
public class PowerBoardEntry implements Serializable{

	/**
	 * this is a generated serial ID
	 */
	private static final long serialVersionUID = -8450979267643633883L;

	public PowerBoardEntry() { }
	
	public PowerBoardEntry(
			String trackName, 
			String driverName, 
			String vehicleName, 
			long lapTime,
			Date dateRecorded)
	{
		this.trackName = trackName;
		this.driverName = driverName;
		this.vehicleName = vehicleName;
		this.lapTime = lapTime; // in seconds
		this.dateRecorded = dateRecorded;
	}
	
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Long id;
	
	@Persistent
	private String driverName;
	// TODO driver will map to authenticated user
	
	@Persistent 
	private Date dateRecorded;
	
	@Persistent
	private long lapTime;
	
	//@Persistent
	//private URL natsoftLink;
	
	@Persistent
	private String vehicleName;
	// TODO vehicle will map to an object/configuration in users profile
	
	@Persistent
	private String trackName;
	
	public Long getId() {
		return id;
	}

	public String getDriverName() {
		return driverName;
	}

	public Date getDateRecorded() {
		return dateRecorded;
	}

	public long getLapTime() {
		return lapTime;
	}

	/*public void setNatsoftList(URL link) {
		this.natsoftLink = link;
	}
		
	public URL getNatsoftLink() {
		return natsoftLink;
	}*/

	public String getVehicleName() {
		return vehicleName;
	}

	public String getTrackName() {
		return trackName;
	}
	
	public String toString() {
		return this.lapTime + " - "+ this.driverName;
	}
	
}
